﻿app.controller('TestController', function ($scope, $http) {

    init();

    function init() {
        $scope.severName = mainFileAddress;
        $scope.sendServer = function () {
            if (myData != null)
                alert('has data');
            else
                alert('null data');
            var imageData = myData;
            $.ajax({
                type: "POST",
                url: 'http://localhost:38550/api/file/ProcessRequest',
                data: {
                    image: imageData
                },
                beforeSend: function () {
                    $("#comment2").text("Start ajax " + imageData.length);
                },
                success: function (data) {
                    $("#comment2").text("Uploaded! " + data);
                    alert('done');
                },
                error: function (request, error) {
                    alert('err');
                    $("#comment2").text("Error! " + error);
                }
            });
            $http.post('http://localhost:38550/api/file/ProcessRequest', imageData).success(function() {
                alert('success');
            }).error(function () {
                alert('err');
            });
        }
    }
});